home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3dm / midi / mdSetTempo.z / mdSetTempo
Encoding:
Text File  |  2002-10-03  |  7.3 KB  |  133 lines

  1.  
  2.  
  3.  
  4. mmmmddddSSSSeeeettttDDDDiiiivvvviiiissssiiiioooonnnn((((3333ddddmmmm))))                                          mmmmddddSSSSeeeettttDDDDiiiivvvviiiissssiiiioooonnnn((((3333ddddmmmm))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      mdSetDivision, mdSetTempo, mdSetTempoScale, mdGetDivision, mdGetTempo,
  10.      mdTickstoNanos, mdNanosToTicks - set tempo and division for a port
  11.  
  12. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.      ####iiiinnnncccclllluuuuddddeeee <<<<ddddmmmmeeeeddddiiiiaaaa////mmmmiiiiddddiiii....hhhh>>>>
  14.  
  15.      iiiinnnntttt mmmmddddSSSSeeeettttDDDDiiiivvvviiiissssiiiioooonnnn((((MMMMDDDDppppoooorrrrtttt ppppoooorrrrtttt,,,, iiiinnnntttt ddddiiiivvvv))))
  16.      iiiinnnntttt mmmmddddSSSSeeeettttTTTTeeeemmmmppppoooo((((MMMMDDDDppppoooorrrrtttt ppppoooorrrrtttt,,,, iiiinnnntttt tttteeeemmmmppppoooo))))
  17.      iiiinnnntttt mmmmddddGGGGeeeettttDDDDiiiivvvviiiissssiiiioooonnnn((((MMMMDDDDppppoooorrrrtttt ppppoooorrrrtttt))))
  18.      iiiinnnntttt mmmmddddGGGGeeeettttTTTTeeeemmmmppppoooo((((MMMMDDDDppppoooorrrrtttt ppppoooorrrrtttt))))
  19.      iiiinnnntttt mmmmddddSSSSeeeettttTTTTeeeemmmmppppoooossssccccaaaalllleeee((((MMMMDDDDppppoooorrrrtttt ppppoooorrrrtttt,,,, ddddoooouuuubbbblllleeee ssssccccaaaalllleeee))))
  20.      lllloooonnnngggg lllloooonnnngggg mmmmddddTTTTiiiicccckkkkssssTTTTooooNNNNaaaannnnoooossss((((MMMMDDDDppppoooorrrrtttt,,,, uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnngggg lllloooonnnngggg))))
  21.      lllloooonnnngggg lllloooonnnngggg mmmmddddNNNNaaaannnnoooossssTTTTooooTTTTiiiicccckkkkssss((((MMMMDDDDppppoooorrrrtttt,,,, uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnngggg lllloooonnnngggg))))
  22.  
  23.  
  24. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  25.      mmmmddddSSSSeeeettttDDDDiiiivvvviiiissssiiiioooonnnn and mmmmddddSSSSeeeettttTTTTeeeemmmmppppoooo specify the conversion from MIDI clock ticks
  26.      to real time values for the MDport.  These functions are only applicable
  27.      when a port is in one of the tick modes (MD_RELATIVETICK or
  28.      MD_DELTATICK); they should not be called with ports in the other stamping
  29.      modes.
  30.  
  31.      The following equation expresses relation of tempo, division, temposcale,
  32.      and tick duration:
  33.  
  34.                                       tempo (usecs/beat)
  35.      tick duration (usecs/tick)  = ----------------------------------
  36.                                     division (ticks/beat) * temposcale
  37.  
  38.      mmmmddddSSSSeeeettttTTTTeeeemmmmppppoooo sets the _t_e_m_p_o in terms of microseconds per beat, the same as
  39.      in Standard MIDI Files.  Tempo may also be set by sending a SET TEMPO
  40.      meta event to an MDport.  Tempo meta events are encoded by placing a 0xFF
  41.      in the _m_s_g[_0] byte of a MDevent structure, setting the _m_s_g_l_e_n field to 6,
  42.      and making the _s_y_s_e_x_m_s_g field point to a block of memory containing the
  43.      following six bytes:
  44.  
  45.      sysexmsg[0]  = 0xff
  46.      sysexmsg[1] = 0x51
  47.      sysexmsg[2] = 0x3
  48.      sysexmsg[3] = xx
  49.      sysexmsg[4] = yy
  50.      sysexmsg[5] = zz
  51.  
  52.      where xx, yy, and zz encode a  24-bit number representing microseconds
  53.      per quarter note.  The tempo is equal to (xx << 16) + (yy << 8) + zz.
  54.  
  55.      mmmmddddSSSSeeeettttDDDDiiiivvvviiiissssiiiioooonnnn sets number of ticks into which a beat is divided.
  56.      Divisions are sometimes referred to as pulses per quarter note and
  57.      correspond to the division field in the MIDI file header chunk.  The
  58.      number of ticks per beat is indicated by the _d_i_v argument.
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. mmmmddddSSSSeeeettttDDDDiiiivvvviiiissssiiiioooonnnn((((3333ddddmmmm))))                                          mmmmddddSSSSeeeettttDDDDiiiivvvviiiissssiiiioooonnnn((((3333ddddmmmm))))
  71.  
  72.  
  73.  
  74.      mdSetTempo and mdSetDivision are irrelevant  if the port is not in one of
  75.      the tick stamping modes (either MD_RELATIVETICK or MD_DELTATICK) and
  76.      should not be called.
  77.  
  78.      mmmmddddGGGGeeeettttTTTTeeeemmmmppppoooo and mmmmddddGGGGeeeettttDDDDiiiivvvviiiissssiiiioooonnnn return the current tempo and division for
  79.      the port.
  80.  
  81.      mmmmddddSSSSeeeettttTTTTeeeemmmmppppoooossssccccaaaalllleeee and mmmmddddGGGGeeeettttTTTTeeeemmmmppppoooossssccccaaaalllleeee set and return a tempo scale value
  82.      for the port.  mdSetTempoScale changes the tempo of a port asychronously,
  83.      and is commonly used for real-time tempo adjustments.   All tick mode
  84.      time stamps written to the port will be divided by this scale before
  85.      being queued for output, so that scale values greater than 1.0 will
  86.      result in a faster playback rate, while values less than 1.0 will result
  87.      is a slower playback rate.
  88.  
  89.      mmmmddddTTTTiiiicccckkkkssssTTTTooooNNNNaaaannnnoooossss and mmmmddddNNNNaaaannnnoooossssTTTTooooTTTTiiiicccckkkkssss allow conversion between ticks and
  90.      nanoseconds using the current tempo on the port.  These routines do not
  91.      take into account previous tempo or tempo scale changes.  In order to
  92.      accurately convert a tick value to an absolute time (or vice-versa), an
  93.      application must maintain a list of all tempo changes in a MIDI stream.
  94.  
  95. RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEE
  96.      mdSetDivision and mdSetTempo return 0 on success and -1 on error.
  97.      mdGetDivision and mdGetTempo return the appropriate value or -1 on error.
  98.      The following error codes are expected:
  99.  
  100.      ENXIO    - Invalid port
  101.  
  102.      EINVAL   - An undefined operation was called.
  103.  
  104. BBBBUUUUGGGGSSSS
  105.      mdGetTempo returns the last tempo set, which is not necessarily the tempo
  106.      currently being used.  In particular, if a MIDI tempo meta event is sent
  107.      to the port, mdGetTempo won't report the tempo change made by the meta
  108.      event.
  109.  
  110. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  111.      mdSetStampMode(3dm)
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.